﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using BCDataCenter.DataAccessLayer;
/// <summary>
/// Summary description for BWUser
/// </summary>
namespace BCDataCenter.BOL
{
    public class BWUser
    {
        string SqlInsert = "UserInsert";
        string SqlUpdate = "UserUpdate";
        string SqlGetData = "UserGetList";
        string SqlIsExistUser = "IsExistUser";
        string SqlGetTTPPList = "UserGetTTPPListFromMis";
        string SqlGetUserLogon = "getUserLogon";

        public BWUser()
        {
            //
            // TODO: Add constructor logic here
            //
        }
        public bool Insert(ref string error, string UserName, string UserDescription, string Password,string passwordHint, bool OneConection, bool Conected, string Sitecode, string UserType, bool Active)
        {
            return new DAL().MyExecuteNonQuery(SqlInsert, System.Data.CommandType.StoredProcedure, ref error,
                new SqlParameter("@UserName", UserName),
                new SqlParameter("@UserDescription", UserDescription),
                new SqlParameter("@Password", Password),
                new SqlParameter("@OneConection", OneConection),
                new SqlParameter("@Conected", Conected),
                new SqlParameter("@Sitecode",Sitecode),
                new SqlParameter("@UserType", UserType),
                new SqlParameter("@Active", Active),
                new SqlParameter("@PasswordHint",passwordHint));
        }

        public bool Update(ref string error, string UserName, string UserDescription, string Password,string passHint, bool OneConection, bool Conected, string Sitecode, string UserType, bool Active)
        {
            return new DAL().MyExecuteNonQuery(SqlUpdate, System.Data.CommandType.StoredProcedure, ref error,
                new SqlParameter("@UserName", UserName),
                new SqlParameter("@UserDescription", UserDescription),
                new SqlParameter("@Password", Password),
                new SqlParameter("@OneConection", OneConection),
                new SqlParameter("@Conected", Conected),
                new SqlParameter("@Sitecode", Sitecode),
                new SqlParameter("@UserType", UserType),
                new SqlParameter("@Active", Active),
                new SqlParameter("@PasswordHint",passHint));
               
        }

        public bool Update(ref string error, string UserName, string Password)
        {
            return new DAL().MyExecuteNonQuery("Update_Password", System.Data.CommandType.StoredProcedure, ref error,
                new SqlParameter("@UserName", UserName),
                new SqlParameter("@Password", Password)
                );
        }
        public System.Data.DataSet dsGetUserLogon(ref string error, string UserName, string Password)
        {
            return new DAL().MyExecuteQuery(ref error, SqlGetUserLogon, System.Data.CommandType.StoredProcedure,
                new SqlParameter("@UserName", UserName),
                new SqlParameter("@Password", Password));
        }
        public System.Data.DataSet dsGetUserViewReportLogon(ref string error, string UserName, string Password)
        {
            return new DAL().MyExecuteQuery(ref error, "Tr_PubgetUserLogOnViewReport", System.Data.CommandType.StoredProcedure,
                new SqlParameter("@MaTVV", UserName),
                new SqlParameter("@Pass", Password));
        }
        public bool IsExistUser(ref string error, string UserName)
        { 
            return new DAL().IsExistFromSQL(SqlIsExistUser, System.Data.CommandType.StoredProcedure, ref error, new SqlParameter("@UserName",UserName));
        }

        public System.Data.DataSet dsList(ref string error)
        {
            return new DAL().MyExecuteReader(ref error, SqlGetData, System.Data.CommandType.StoredProcedure);
        }
        public System.Data.DataSet dsTTPPList(ref string error)
        {
            return new DAL().MyExecuteReader(ref error, SqlGetTTPPList, System.Data.CommandType.StoredProcedure);
        }
    }
}
